<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Grupo12daturma2MIEIC4: C:/Users/Paulo/Documents/FEUP/EclipseWorkSpace/calgrafos/src/mapas.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<!-- Gerado por Doxygen 1.7.4 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Localizar');
--></script>
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">Grupo12daturma2MIEIC4&#160;<span id="projectnumber">1.0</span></div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Página&#160;principal</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Ficheiros</span></a></li>
      <li id="searchli">
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Localizar" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>Lista&#160;de&#160;ficheiros</span></a></li>
      <li><a href="globals.html"><span>Ficheiros&#160;membro</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('mapas_8cpp.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">C:/Users/Paulo/Documents/FEUP/EclipseWorkSpace/calgrafos/src/mapas.cpp</div>  </div>
</div>
<div class="contents">
<a href="mapas_8cpp.html">Ir para a documentação deste ficheiro.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">//============================================================================</span>
<a name="l00002"></a>00002 <span class="comment">// Nome        : mapas.cpp</span>
<a name="l00003"></a>00003 <span class="comment">// Autores     : T1G7</span>
<a name="l00004"></a>00004 <span class="comment">//                                      Felipe Galvão do Espírito Santo</span>
<a name="l00005"></a>00005 <span class="comment">//                                      Ivanilda Maísa Costa Brazão de Almeida</span>
<a name="l00006"></a>00006 <span class="comment">//                                      Paulo Jorge de Faria dos Reis</span>
<a name="l00007"></a>00007 <span class="comment">// Versão      : 1.0</span>
<a name="l00008"></a>00008 <span class="comment">// Data        : Maio de 2011</span>
<a name="l00009"></a>00009 <span class="comment">// Copyright   : Creative Commons 2.0</span>
<a name="l00010"></a>00010 <span class="comment">// Descrição   : CAL 2011 - TG1</span>
<a name="l00011"></a>00011 <span class="comment">//               Tema 12 - Transporte de pacientes de uma clínica de saúde.</span>
<a name="l00012"></a>00012 <span class="comment">//============================================================================</span>
<a name="l00013"></a>00013 
<a name="l00014"></a>00014 <span class="preprocessor">#include &quot;<a class="code" href="mapas_8h.html">mapas.h</a>&quot;</span>
<a name="l00015"></a>00015 
<a name="l00016"></a>00016 
<a name="l00019"></a><a class="code" href="classno.html#a7a012e719eafb9b631ab7a42cd15a716">00019</a> <a class="code" href="classno.html#a7a012e719eafb9b631ab7a42cd15a716">no::no</a>(<span class="keywordtype">string</span> linha)
<a name="l00020"></a>00020 {
<a name="l00021"></a>00021         <span class="keywordflow">try</span>
<a name="l00022"></a>00022         {
<a name="l00023"></a>00023                 <span class="keywordflow">if</span>(sscanf(linha.c_str(), <span class="stringliteral">&quot;%d;%f;%f;%f;%f&quot;</span>, &amp;<a class="code" href="classno.html#ac517e6c74e70237ef721d67836e2a9f3" title="Dados a guardar no n�">identificador</a>, &amp;<a class="code" href="classno.html#ac63dfdd6840b84e561d5eff5ba0941f7">posX</a>, &amp;<a class="code" href="classno.html#aaf3d66c0aa5c8668dd7159005e59cf1d">posY</a>, &amp;<a class="code" href="classno.html#a8f48fc489a7d01ee82875808e6212b9c">projX</a>, &amp;<a class="code" href="classno.html#a779b0592609d02c60d00bc8dc17970a9">projY</a>) == EOF) <span class="keywordflow">throw</span>(linha.c_str());  
<a name="l00024"></a>00024         }
<a name="l00025"></a>00025         <span class="keywordflow">catch</span>(<span class="keywordtype">char</span> * erro)
<a name="l00026"></a>00026         {
<a name="l00027"></a>00027                 cout &lt;&lt; <span class="stringliteral">&quot;Erro a processar os dados:&quot;</span> &lt;&lt; endl;
<a name="l00028"></a>00028                 cout &lt;&lt; erro &lt;&lt; endl;
<a name="l00029"></a>00029                 <span class="comment">//TODO Código para processar a entrada manual do no.</span>
<a name="l00030"></a>00030         }
<a name="l00031"></a>00031 }
<a name="l00032"></a>00032 
<a name="l00034"></a><a class="code" href="classno.html#a3fe66c31bbfcca1c83fc938c5868906d">00034</a> <a class="code" href="classno.html#a3fe66c31bbfcca1c83fc938c5868906d" title="Recebe uma string contendo uma linha do ficheiro de nodes obtidos da adapta��o do OSM...">no::~no</a>()
<a name="l00035"></a>00035 {
<a name="l00036"></a>00036 }
<a name="l00037"></a>00037 
<a name="l00038"></a><a class="code" href="classno.html#ab1e7cc5605ab0feecc6383b352fbdf4c">00038</a> <span class="keywordtype">bool</span> <a class="code" href="classno.html#ab1e7cc5605ab0feecc6383b352fbdf4c" title="Destrutor.">no::operator== </a>(<a class="code" href="classno.html" title="Classe que define um ponto geográfico.">no</a> no1)
<a name="l00039"></a>00039 {
<a name="l00040"></a>00040         <span class="keywordflow">if</span>(this-&gt;<a class="code" href="classno.html#ac517e6c74e70237ef721d67836e2a9f3" title="Dados a guardar no n�">identificador</a> == no1.<a class="code" href="classno.html#ac517e6c74e70237ef721d67836e2a9f3" title="Dados a guardar no n�">identificador</a>)
<a name="l00041"></a>00041                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00042"></a>00042         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00043"></a>00043 }
<a name="l00044"></a>00044 
<a name="l00045"></a><a class="code" href="classno.html#aa1b93bb203f0a1dfd4cd906ed33fc334">00045</a> <span class="keywordtype">int</span> <a class="code" href="classno.html#aa1b93bb203f0a1dfd4cd906ed33fc334" title="Operador igualdade necessário para a utilização do algoritmo Dijkstra.">no::getID</a>()
<a name="l00046"></a>00046 {
<a name="l00047"></a>00047         <span class="keywordflow">return</span> this-&gt;<a class="code" href="classno.html#ac517e6c74e70237ef721d67836e2a9f3" title="Dados a guardar no n�">identificador</a>;
<a name="l00048"></a>00048 }
<a name="l00049"></a>00049 
<a name="l00050"></a><a class="code" href="classno.html#abd6c57022c032f4953833bdce662e917">00050</a> <span class="keywordtype">float</span> <a class="code" href="classno.html#abd6c57022c032f4953833bdce662e917" title="Devolve o identificador de um nó do vector de pontos.">no::latitude</a>()
<a name="l00051"></a>00051 {
<a name="l00052"></a>00052         <span class="keywordflow">return</span> <a class="code" href="classno.html#aaf3d66c0aa5c8668dd7159005e59cf1d">posY</a>;
<a name="l00053"></a>00053 }
<a name="l00054"></a>00054 
<a name="l00055"></a><a class="code" href="classno.html#ad85f4b9030e74db678640b53d97b117f">00055</a> <span class="keywordtype">float</span> <a class="code" href="classno.html#ad85f4b9030e74db678640b53d97b117f">no::longitude</a>()
<a name="l00056"></a>00056 {
<a name="l00057"></a>00057         <span class="keywordflow">return</span> <a class="code" href="classno.html#ac63dfdd6840b84e561d5eff5ba0941f7">posX</a>;
<a name="l00058"></a>00058 }
<a name="l00059"></a>00059 
<a name="l00060"></a><a class="code" href="classmapa.html#ab3b560dc9bdab6b63ed079aa5cf85a0f">00060</a> <a class="code" href="classno.html" title="Classe que define um ponto geográfico.">no</a>&amp; <a class="code" href="classmapa.html#ab3b560dc9bdab6b63ed079aa5cf85a0f" title="Criar uma rota mais curta.">mapa::noPorID</a>(<span class="keywordtype">int</span> ident)
<a name="l00061"></a>00061 {
<a name="l00062"></a>00062         <span class="keywordflow">for</span>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; <a class="code" href="classmapa.html#a0778ef30778f978a7f476b2b5c1e7076" title="cima">pontos</a>.size(); i++)
<a name="l00063"></a>00063         {
<a name="l00064"></a>00064                 <span class="keywordflow">if</span>(ident == <a class="code" href="classmapa.html#a0778ef30778f978a7f476b2b5c1e7076" title="cima">pontos</a>[i].getID())
<a name="l00065"></a>00065                         <span class="keywordflow">return</span> <a class="code" href="classmapa.html#a0778ef30778f978a7f476b2b5c1e7076" title="cima">pontos</a>[i];
<a name="l00066"></a>00066         }
<a name="l00067"></a>00067 }
<a name="l00068"></a>00068 
<a name="l00071"></a><a class="code" href="classmorada.html#a54974c7766d798159100aa9052439924">00071</a> <a class="code" href="classmorada.html#a54974c7766d798159100aa9052439924">morada::morada</a>(<span class="keywordtype">string</span> linha)
<a name="l00072"></a>00072 {
<a name="l00073"></a>00073         <span class="comment">//string sentido;</span>
<a name="l00074"></a>00074         <span class="comment">//try</span>
<a name="l00075"></a>00075         <span class="comment">//{</span>
<a name="l00076"></a>00076         <span class="comment">//      if(sscanf(linha.c_str(), &quot;%d;%s;%s&quot;, &amp;identificador, &amp;nome, &amp;sentido) == EOF)</span>
<a name="l00077"></a>00077         <span class="comment">//      {</span>
<a name="l00078"></a>00078         <span class="comment">//                      throw(linha.c_str());   //! identificador;nome;sentido</span>
<a name="l00079"></a>00079         <span class="comment">//      }</span>
<a name="l00080"></a>00080         <span class="comment">//      if(sentido == &quot;False&quot;)</span>
<a name="l00081"></a>00081         <span class="comment">//      {</span>
<a name="l00082"></a>00082         <span class="comment">//              umSentido = false;</span>
<a name="l00083"></a>00083         <span class="comment">//      }</span>
<a name="l00084"></a>00084         <span class="comment">//      else</span>
<a name="l00085"></a>00085         <span class="comment">//      {</span>
<a name="l00086"></a>00086         <span class="comment">//              umSentido = true; </span>
<a name="l00087"></a>00087         <span class="comment">//      }</span>
<a name="l00088"></a>00088         <span class="comment">//}</span>
<a name="l00089"></a>00089         <span class="comment">//catch(char * erro)</span>
<a name="l00090"></a>00090         <span class="comment">//{</span>
<a name="l00091"></a>00091         <span class="comment">//      cout &lt;&lt; &quot;Erro a processar os dados:&quot; &lt;&lt; endl;</span>
<a name="l00092"></a>00092         <span class="comment">//      cout &lt;&lt; erro &lt;&lt; endl;</span>
<a name="l00093"></a>00093         <span class="comment">//      //cout &lt;&lt; &quot;Pretende:&quot; &lt;&lt; endl;</span>
<a name="l00094"></a>00094         <span class="comment">//      //cout &lt;&lt; &quot;1 - ignorar este n�&quot; &lt;&lt; endl;</span>
<a name="l00095"></a>00095         <span class="comment">//      //cout &lt;&lt; &quot;2 - introduzir os dados manualmente&quot; &lt;&lt; endl;</span>
<a name="l00096"></a>00096         <span class="comment">//      //cout &lt;&lt; &quot;3 - Cancelar o carregamento e terminar a aplica��o&quot; &lt;&lt; endl;</span>
<a name="l00097"></a>00097         <span class="comment">//      </span>
<a name="l00098"></a>00098         <span class="comment">//      //TODO C�digo para processar a entrada manual da morada.</span>
<a name="l00099"></a>00099         <span class="comment">//}</span>
<a name="l00100"></a>00100 }
<a name="l00101"></a>00101 
<a name="l00103"></a><a class="code" href="classmorada.html#a8cc0dbeb7f9c39afad4464437bd9c12c">00103</a> <a class="code" href="classmorada.html#a8cc0dbeb7f9c39afad4464437bd9c12c" title="identificador da rua;nome da rua;rua de um sentido(true,false)">morada::~morada</a>()
<a name="l00104"></a>00104 {
<a name="l00105"></a>00105 }
<a name="l00106"></a>00106 
<a name="l00109"></a><a class="code" href="classunidade.html#a6e5b33527c9c71195ad3571deb8a2246">00109</a> <a class="code" href="classunidade.html#a6e5b33527c9c71195ad3571deb8a2246">unidade::unidade</a>(<span class="keywordtype">string</span> linha)
<a name="l00110"></a>00110 {
<a name="l00111"></a>00111         <span class="keywordflow">try</span>
<a name="l00112"></a>00112         {
<a name="l00113"></a>00113                 <span class="keywordflow">if</span>(sscanf(linha.c_str(), <span class="stringliteral">&quot;%d;%d;%d&quot;</span>, &amp;<a class="code" href="classunidade.html#a629ba40fba2aebf1e655e411b0dc9892">identificador</a>, &amp;<a class="code" href="classunidade.html#ad28454c997973a909804f43b434753c8">inicio</a>, &amp;<a class="code" href="classunidade.html#a4f5131e77f9ccdda0b2c06eb0137d3e0">fim</a>) == EOF) <span class="keywordflow">throw</span>(linha.c_str());       
<a name="l00114"></a>00114         }
<a name="l00115"></a>00115         <span class="keywordflow">catch</span>(<span class="keywordtype">char</span> * erro)
<a name="l00116"></a>00116         {
<a name="l00117"></a>00117                 cout &lt;&lt; <span class="stringliteral">&quot;Erro a processar os dados:&quot;</span> &lt;&lt; endl;
<a name="l00118"></a>00118                 cout &lt;&lt; erro &lt;&lt; endl;
<a name="l00119"></a>00119         }
<a name="l00120"></a>00120 }
<a name="l00121"></a>00121 
<a name="l00123"></a><a class="code" href="classunidade.html#a2aeff592997427253c50f426b652bb25">00123</a> <a class="code" href="classunidade.html#a2aeff592997427253c50f426b652bb25" title="identificador da rua;identificador do n� origem;identificador do n� destino;">unidade::~unidade</a>()
<a name="l00124"></a>00124 {
<a name="l00125"></a>00125 }
<a name="l00126"></a>00126 
<a name="l00127"></a><a class="code" href="classunidade.html#ae57ce8f6905d55582931f1a7d8fc8f0b">00127</a> <span class="keywordtype">int</span> <a class="code" href="classunidade.html#ae57ce8f6905d55582931f1a7d8fc8f0b">unidade::noInicio</a>()
<a name="l00128"></a>00128 {
<a name="l00129"></a>00129         <span class="keywordflow">return</span> <a class="code" href="classunidade.html#ad28454c997973a909804f43b434753c8">inicio</a>;
<a name="l00130"></a>00130 }
<a name="l00131"></a>00131 
<a name="l00132"></a><a class="code" href="classunidade.html#a49933b012aae5c496e5b4ddd5c73f59c">00132</a> <span class="keywordtype">int</span> <a class="code" href="classunidade.html#a49933b012aae5c496e5b4ddd5c73f59c">unidade::noFinal</a>()
<a name="l00133"></a>00133 {
<a name="l00134"></a>00134         <span class="keywordflow">return</span> <a class="code" href="classunidade.html#a4f5131e77f9ccdda0b2c06eb0137d3e0">fim</a>;
<a name="l00135"></a>00135 }
<a name="l00136"></a>00136 
<a name="l00137"></a>00137 
<a name="l00140"></a><a class="code" href="classmapa.html#ab117dbe9491acc8a73d58415d0e5d95d">00140</a> <a class="code" href="classmapa.html#ab117dbe9491acc8a73d58415d0e5d95d">mapa::mapa</a>(<span class="keywordtype">float</span> esquerda, <span class="keywordtype">float</span> direita, <span class="keywordtype">float</span> cima, <span class="keywordtype">float</span> baixo, <span class="keywordtype">int</span> X, <span class="keywordtype">int</span> Y)
<a name="l00141"></a>00141 {
<a name="l00142"></a>00142         <a class="code" href="classmapa.html#a5c3da8633f4005f7c7edfc089668d01c" title="Devolve uma referência para um nó a partir do seu identificador.">horizontal</a> = X;                                 
<a name="l00143"></a>00143         <a class="code" href="classmapa.html#ac123c36468b41d573ff5b28fc6d842c7" title="X.">vertical</a> = Y;                                   
<a name="l00144"></a>00144         <a class="code" href="classmapa.html#a4ccbcb32e32c3f3fc5ed81264adadf06" title="Y.">longitudeMin</a> = esquerda;                
<a name="l00145"></a>00145         <a class="code" href="classmapa.html#acc5a9aa327a2beea8926ffe87a23feb2" title="esquerda">longitudeMax</a> = direita;                 
<a name="l00146"></a>00146         <a class="code" href="classmapa.html#a8604276b258cacb5c0b89bc2898f565f" title="direita">latitudeMin</a> = baixo;                    
<a name="l00147"></a>00147         <a class="code" href="classmapa.html#acfeb9cd704d1e797721a3ac548afca69" title="baixo">latitudeMax</a> = cima;                             
<a name="l00148"></a>00148 }
<a name="l00149"></a>00149 
<a name="l00151"></a><a class="code" href="classmapa.html#a8a354d662effb4411a967ec3ba8de6c7">00151</a> <a class="code" href="classmapa.html#a8a354d662effb4411a967ec3ba8de6c7" title="Cria um mapa indicando as coordenadas minimas e maximas e a dimensão do mapa.">mapa::~mapa</a>()
<a name="l00152"></a>00152 {
<a name="l00153"></a>00153 }
<a name="l00154"></a>00154 
<a name="l00156"></a><a class="code" href="classmapa.html#afcab2a0230fc1022aa740d701af345b1">00156</a> <span class="keywordtype">void</span> <a class="code" href="classmapa.html#afcab2a0230fc1022aa740d701af345b1" title="Leitura dos ficheiros de dados e carregamentos da informação.">mapa::processaMapa</a>(<span class="keywordtype">char</span> * fNodes, <span class="keywordtype">char</span> * fRuas, <span class="keywordtype">char</span> * fSubruas)
<a name="l00157"></a>00157 {
<a name="l00158"></a>00158         <span class="keywordtype">string</span> linha;
<a name="l00159"></a>00159 
<a name="l00161"></a>00161         fstream fNos(fNodes);
<a name="l00162"></a>00162         <span class="keywordflow">while</span>(getline(fNos, linha))
<a name="l00163"></a>00163         {
<a name="l00164"></a>00164                 <a class="code" href="classmapa.html#a0778ef30778f978a7f476b2b5c1e7076" title="cima">pontos</a>.push_back(<a class="code" href="classno.html" title="Classe que define um ponto geográfico.">no</a>(linha));
<a name="l00165"></a>00165                 <a class="code" href="classmapa.html#acab9ebb8899f41f52d11631add616f9a" title="Este é o grafo para o DijKstra.">grafoDoMapa</a>.<a class="code" href="class_graph.html#a00be284ea2be3b3d0f0d2e493b70245b">addVertex</a>(<a class="code" href="classmapa.html#a0778ef30778f978a7f476b2b5c1e7076" title="cima">pontos</a>.end()-&gt;getID());
<a name="l00166"></a>00166                 <a class="code" href="classmapa.html#a9201227ee79c8084fe5691254ec950a8" title="Sub ruas, a localização mais pequena que se pode definir.">grafoDoMapa2</a>.<a class="code" href="class_graph.html#a00be284ea2be3b3d0f0d2e493b70245b">addVertex</a>(<a class="code" href="classmapa.html#ab3b560dc9bdab6b63ed079aa5cf85a0f" title="Criar uma rota mais curta.">noPorID</a>(<a class="code" href="classmapa.html#a0778ef30778f978a7f476b2b5c1e7076" title="cima">pontos</a>.end()-&gt;getID()));
<a name="l00167"></a>00167         }
<a name="l00168"></a>00168         fNos.close();
<a name="l00169"></a>00169         cout &lt;&lt; <span class="stringliteral">&quot;Processados &quot;</span> &lt;&lt; <a class="code" href="classmapa.html#a0778ef30778f978a7f476b2b5c1e7076" title="cima">pontos</a>.size() &lt;&lt; <span class="stringliteral">&quot; nós geográficos, a partir do ficheiro &quot;</span> &lt;&lt; fNodes &lt;&lt; endl;
<a name="l00170"></a>00170         cout &lt;&lt; <span class="stringliteral">&quot;Existem &quot;</span> &lt;&lt; <a class="code" href="classmapa.html#acab9ebb8899f41f52d11631add616f9a" title="Este é o grafo para o DijKstra.">grafoDoMapa</a>.<a class="code" href="class_graph.html#a295932f117d92c825a97ec458e0fb332">getNumVertex</a>() &lt;&lt; <span class="stringliteral">&quot; nós no grafoDoMapa&quot;</span> &lt;&lt; endl;
<a name="l00171"></a>00171         cout &lt;&lt; <span class="stringliteral">&quot;Existem &quot;</span> &lt;&lt; <a class="code" href="classmapa.html#a9201227ee79c8084fe5691254ec950a8" title="Sub ruas, a localização mais pequena que se pode definir.">grafoDoMapa2</a>.<a class="code" href="class_graph.html#a295932f117d92c825a97ec458e0fb332">getNumVertex</a>() &lt;&lt; <span class="stringliteral">&quot; nós no grafoDoMapa2&quot;</span> &lt;&lt; endl;
<a name="l00172"></a>00172 
<a name="l00174"></a>00174         fstream fVias(fRuas);
<a name="l00175"></a>00175         <span class="keywordflow">while</span>(getline(fVias, linha))
<a name="l00176"></a>00176         {
<a name="l00177"></a>00177                 <a class="code" href="classmapa.html#a3c9a8d8abeef93fd59e9a75f58fb3027" title="Colecção dos nós geográficos de um mapa.">arruamentos</a>.push_back(<a class="code" href="classmorada.html" title="Ruas de um mapa.">morada</a>(linha));
<a name="l00178"></a>00178         }
<a name="l00179"></a>00179         fVias.close();
<a name="l00180"></a>00180         cout &lt;&lt; <span class="stringliteral">&quot;Processadas &quot;</span> &lt;&lt; <a class="code" href="classmapa.html#a3c9a8d8abeef93fd59e9a75f58fb3027" title="Colecção dos nós geográficos de um mapa.">arruamentos</a>.size() &lt;&lt; <span class="stringliteral">&quot; ruas, a partir do ficheiro &quot;</span> &lt;&lt; fRuas &lt;&lt; endl;
<a name="l00181"></a>00181 
<a name="l00183"></a>00183         fstream fPontos(fSubruas);
<a name="l00184"></a>00184         <span class="keywordflow">while</span>(getline(fPontos, linha))
<a name="l00185"></a>00185         {
<a name="l00186"></a>00186                 <a class="code" href="classmapa.html#aa31bd8c404a671ac96e41c67c25b238f" title="Ruas do mapa.">pontosInteresse</a>.push_back(<a class="code" href="classunidade.html" title="Ponto de localiza��o geogr�fico.">unidade</a>(linha));
<a name="l00187"></a>00187                 <span class="keywordtype">double</span> lat1 = (<a class="code" href="classmapa.html#a1e5a2eea483d0a946af3f8eaad45bf01" title="Depois de criar um mapa é necessário carregar o mesmo com a informação.">infoNo</a>((<a class="code" href="classmapa.html#aa31bd8c404a671ac96e41c67c25b238f" title="Ruas do mapa.">pontosInteresse</a>.end())-&gt;noInicio()))-&gt;latitude();
<a name="l00188"></a>00188                 <span class="keywordtype">double</span> lat2 = (<a class="code" href="classmapa.html#a1e5a2eea483d0a946af3f8eaad45bf01" title="Depois de criar um mapa é necessário carregar o mesmo com a informação.">infoNo</a>((<a class="code" href="classmapa.html#aa31bd8c404a671ac96e41c67c25b238f" title="Ruas do mapa.">pontosInteresse</a>.end())-&gt;noFinal()))-&gt;latitude();
<a name="l00189"></a>00189                 <span class="keywordtype">double</span> long1 = (<a class="code" href="classmapa.html#a1e5a2eea483d0a946af3f8eaad45bf01" title="Depois de criar um mapa é necessário carregar o mesmo com a informação.">infoNo</a>((<a class="code" href="classmapa.html#aa31bd8c404a671ac96e41c67c25b238f" title="Ruas do mapa.">pontosInteresse</a>.end())-&gt;noInicio()))-&gt;longitude();
<a name="l00190"></a>00190                 <span class="keywordtype">double</span> long2 = (<a class="code" href="classmapa.html#a1e5a2eea483d0a946af3f8eaad45bf01" title="Depois de criar um mapa é necessário carregar o mesmo com a informação.">infoNo</a>((<a class="code" href="classmapa.html#aa31bd8c404a671ac96e41c67c25b238f" title="Ruas do mapa.">pontosInteresse</a>.end())-&gt;noFinal()))-&gt;longitude();
<a name="l00191"></a>00191 
<a name="l00192"></a>00192                 <a class="code" href="classmapa.html#acab9ebb8899f41f52d11631add616f9a" title="Este é o grafo para o DijKstra.">grafoDoMapa</a>.<a class="code" href="class_graph.html#ac61af3aafe6277215f5a3b3cc7d58ce2">addEdge</a>((<a class="code" href="classmapa.html#aa31bd8c404a671ac96e41c67c25b238f" title="Ruas do mapa.">pontosInteresse</a>.end())-&gt;noInicio(), (<a class="code" href="classmapa.html#aa31bd8c404a671ac96e41c67c25b238f" title="Ruas do mapa.">pontosInteresse</a>.end())-&gt;noFinal(), fabs(<a class="code" href="_auxiliar_8cpp.html#ac968476bd197b7251fa7f8fd3f6cd227" title="Calcula a distância entre 2 posições geográficas.">haversine_m</a>(lat1, long1, lat2, long2)));
<a name="l00193"></a>00193                 <span class="comment">//grafoDoMapa2.addEdge(noPorID((pontosInteresse.end())-&gt;noInicio()), noPorID((pontosInteresse.end())-&gt;noFinal()), fabs(haversine_m(lat1, long1, lat2, long2)));</span>
<a name="l00194"></a>00194         }
<a name="l00195"></a>00195         fPontos.close();
<a name="l00196"></a>00196         cout &lt;&lt; <span class="stringliteral">&quot;Processadas &quot;</span> &lt;&lt; <a class="code" href="classmapa.html#aa31bd8c404a671ac96e41c67c25b238f" title="Ruas do mapa.">pontosInteresse</a>.size() &lt;&lt; <span class="stringliteral">&quot; ruas, a partir do ficheiro &quot;</span> &lt;&lt; fSubruas &lt;&lt; endl;
<a name="l00197"></a>00197 }
<a name="l00198"></a>00198 
<a name="l00199"></a>00199 
<a name="l00200"></a><a class="code" href="classmapa.html#a1e5a2eea483d0a946af3f8eaad45bf01">00200</a> vector&lt;no&gt;::iterator <a class="code" href="classmapa.html#a1e5a2eea483d0a946af3f8eaad45bf01" title="Depois de criar um mapa é necessário carregar o mesmo com a informação.">mapa::infoNo</a>(<span class="keywordtype">int</span> <span class="keywordtype">id</span>)
<a name="l00201"></a>00201 {
<a name="l00202"></a>00202         vector&lt;no&gt;::iterator iter;
<a name="l00203"></a>00203         <span class="keywordflow">for</span>(iter = <a class="code" href="classmapa.html#a0778ef30778f978a7f476b2b5c1e7076" title="cima">pontos</a>.begin(); iter != <a class="code" href="classmapa.html#a0778ef30778f978a7f476b2b5c1e7076" title="cima">pontos</a>.end(); iter++)
<a name="l00204"></a>00204         {
<a name="l00205"></a>00205                 <span class="keywordflow">if</span>(iter-&gt;getID() == id) <span class="keywordflow">return</span> iter;
<a name="l00206"></a>00206         }
<a name="l00207"></a>00207         <span class="keywordflow">return</span> iter;
<a name="l00208"></a>00208 }
<a name="l00209"></a>00209 
<a name="l00210"></a><a class="code" href="classmapa.html#a4c07656152b4e173ac5cdf33944d3e4d">00210</a> vector&lt;no&gt;::iterator <a class="code" href="classmapa.html#a4c07656152b4e173ac5cdf33944d3e4d" title="Devolve um iterador para um nó a partir do identificador do nó geográfico.">mapa::primeiro</a>()
<a name="l00211"></a>00211 {
<a name="l00212"></a>00212         vector&lt;no&gt;::iterator iter;
<a name="l00213"></a>00213         iter = <a class="code" href="classmapa.html#a0778ef30778f978a7f476b2b5c1e7076" title="cima">pontos</a>.begin();
<a name="l00214"></a>00214         <span class="keywordflow">return</span> iter;
<a name="l00215"></a>00215 }
<a name="l00216"></a>00216 
<a name="l00218"></a>00218 
<a name="l00224"></a><a class="code" href="classmapa.html#a8b5ad7d946c73aaded28861546357619">00224</a> <span class="keywordtype">void</span> <a class="code" href="classmapa.html#a8b5ad7d946c73aaded28861546357619" title="Iterador para o primeiro elemento do vector de pontos.">mapa::planearRotas</a>(vector&lt;int&gt;* rotas, vector&lt;int&gt;* avisitar, <span class="keywordtype">int</span> lugares)
<a name="l00225"></a>00225 {
<a name="l00226"></a>00226         <span class="keywordflow">for</span>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i &lt; avisitar-&gt;size(); i++)
<a name="l00227"></a>00227         {
<a name="l00229"></a>00229 
<a name="l00230"></a>00230                 cout &lt;&lt; <span class="stringliteral">&quot;Vou chamar o Dij com &quot;</span> &lt;&lt; avisitar-&gt;at(i) &lt;&lt; endl;
<a name="l00231"></a>00231 <span class="comment">//              grafoDoMapa.dijkstraShortestPath(avisitar-&gt;at(i));</span>
<a name="l00232"></a>00232 <span class="comment">//              cout &lt;&lt; &quot;Depois do Dij &quot; &lt;&lt; i &lt;&lt; endl;</span>
<a name="l00233"></a>00233 <span class="comment">//               TODO optimização para escolher o destino mais perto dos que temos de visitar. E utilizar esse como destino e n�o o seguinte da lista.</span>
<a name="l00234"></a>00234 <span class="comment">//              unsigned int j = i + 1; //! Juntar os pontos a visitar.</span>
<a name="l00235"></a>00235 <span class="comment">//              if(j == avisitar-&gt;size())</span>
<a name="l00236"></a>00236 <span class="comment">//              {</span>
<a name="l00237"></a>00237 <span class="comment">//                      j = 0;  //! Se estivermos na última recolha, voltar à &#39;base&#39;.</span>
<a name="l00238"></a>00238 <span class="comment">//              }</span>
<a name="l00239"></a>00239 <span class="comment">//              vector&lt;int&gt; etapa = grafoDoMapa.getPath(avisitar-&gt;at(i), avisitar-&gt;at(j));</span>
<a name="l00240"></a>00240 <span class="comment">//              for(unsigned int k = 0; k &lt; etapa.size(); k++)</span>
<a name="l00241"></a>00241 <span class="comment">//              {</span>
<a name="l00242"></a>00242 <span class="comment">//                      rotas-&gt;push_back(etapa[k]);</span>
<a name="l00243"></a>00243 <span class="comment">//              }</span>
<a name="l00244"></a>00244         }
<a name="l00245"></a>00245 }
</pre></div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="mapas_8cpp.html">mapas.cpp</a>      </li>
      <li class="footer">Gerado em Fri May 13 2011 02:00:24 para Grupo12daturma2MIEIC4 por&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>Tudo</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Ficheiros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Funções</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variáveis</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Amigos</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Macros</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>


</body>
</html>
